/*
 * =====================================================================================
 *
 *       Filename:  cl_mutex.cxx
 *
 *    Description:  
 *
 *        Version:  1.0
 *        Created:  10/08/2010 10:34:56 PM
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  Ken Chen (Ziliang), zlchen.ken@gmail.com
 *        Company:  EMC
 *
 * =====================================================================================
 */

#include "cl_mutex.hxx"

namespace neo 
{

CLMutex::CLMutex()
{
	pthread_mutexattr_init(&m_mutexAttr);
	pthread_mutex_init(&m_mutex, &m_mutexAttr);
}

CLMutex::~CLMutex()
{
	pthread_mutex_destroy(&m_mutex);
	pthread_mutexattr_destroy(&m_mutexAttr);
}

int CLMutex::doLock(void)
{
  return pthread_mutex_lock(&m_mutex);
}

int CLMutex::doTryLock(void)
{
  return pthread_mutex_trylock(&m_mutex);
}

int CLMutex::doUnLock(void)
{
  return pthread_mutex_unlock(&m_mutex);
}

pthread_mutex_t* CLMutex::getMutex(void)  
{
	return &m_mutex;
}

}// neo
